package com.example.mapper;

import com.example.model.order.Order;
import com.example.model.order.OrderAddRequest;
import com.example.model.order.OrderAllInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {
    //生成订单
    @Insert("insert into orders(order_number,order_status ,hotel_id, room_id, user_id, check_in_date, check_out_date)" +
            "values (#{orderNumber},#{orderStatus},#{hotelId},#{roomId},#{userId},#{checkInDate},#{checkOutDate})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Long add(Order order);

    //根据id查询订单详细信息
    OrderAllInfo getById(Long id);

    //根据用户id获取订单信息
    List<OrderAllInfo> getByUserId(Long userId);

    //获取所有订单
    List<OrderAllInfo> getAllOrder(String orderNumber,Long hotelId,String username);

    //根据酒店获取订单信息
    List<OrderAllInfo> getByHotelId(Long hotelId);

    //根据id获取订单状态
    @Select("select order_status from orders where id=#{id};")
    Integer getOrderStatus(Long id);

    //设置订单状态
    @Update("update orders set order_status=#{status} where id=#{id}")
    Boolean setOrderStatus(Long id, Integer status);
}
